class CodeEntity {
  constructor (code = '', msg = '') {
    this.code = code
    this.msg = msg
  }
}

const ErrorCode = new Map([
  // normal httpError
  ['SUCCESS', new CodeEntity(200, '请求成功')],
  ['BAD_REQUEST', new CodeEntity(400, '请求失败')],
  ['UNAUTHORIZED', new CodeEntity(401, '尚未登录')],
  ['FORBIDDEN', new CodeEntity(403, '没有访问权限')],
  ['INTERNAL_SERVER_ERROR', new CodeEntity(500, '服务器异常')],
  ['SQL_ERROR', new CodeEntity(3000, '数据库操作错误')],
  ['SQL_DATA_ERROR', new CodeEntity(3001, '数据错误')],
  ['JSON_ERROR', new CodeEntity(3010, 'JSON 操作错误')],
  ['EXCEL_ERROR', new CodeEntity(3020, 'EXCEL 操作错误')],
  ['ACCOUNT_PASSWORD_ERROR', new CodeEntity(3030, '账户或密码错误')],
  ['ACCOUNT_NOT_EXIST', new CodeEntity(3031, '用户不存在')],
  ['OLD_PASSWORD_ERROR', new CodeEntity(3030, '密码错误')],
  ['UPLOAD_ERROR', new CodeEntity(3040, '文件上传错误')],
  ['PARAMS_ERROR', new CodeEntity(3050, '参数错误')],
  ['CODING_ERROR', new CodeEntity(3051, '编码错误')],
  // ModelError 1000 ~ 1999
  // User & Login 1000 ~ 1099
  ['ACC_NOT_NULl', new CodeEntity(1000, '账号不能为空！')],
  ['ACC_FORMAT_ERROR', new CodeEntity(1001, '账号格式错误！')],
  ['PWD_NOT_NULL', new CodeEntity(1010, '密码不能为空！')],
  ['PWD_FORMAT_ERROR', new CodeEntity(1011, '密码格式错误！')],
  ['', new CodeEntity(1011, '密码格式错误！')],
  // NormalError 2000 ~ 2999
  ['NOT_NULl', new CodeEntity(2000, '不能为空！')],
  ['NOT_BOTH_NULl', new CodeEntity(2001, '不能同时为空！')],
  ['LESS_THAN_MIN_LEN', new CodeEntity(2010, '小于最小长度！')],
  ['MIN_LEN_IS', new CodeEntity(2011, '最小长度为')],
  ['MORE_THAN_MAX_LEN', new CodeEntity(2020, '超过最小长度！')],
  ['MAX_LEN_IS', new CodeEntity(2021, '最大长度为')],
  ['FORMAT_ERROR', new CodeEntity(2030, '格式错误！')]
])

export default ErrorCode
